<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
    <style type="text/css">
        .fixed-btn{
            position: fixed;
            right: 0.4rem;
            bottom: 0.6rem;
            z-index: 100;
        }
        .fixed-btn a{
            display: block;
            width: 0.8rem;
            height: 0.8rem;
            border-radius: 50%;
        }
        .fixed-btn .reload-view{
            background: #ff7777 url("../../icon/icon-reload.png") center no-repeat;
            background-size: auto 0.4rem;
        }
        .fixed-btn .reload-view:active{
            background: #ff9d7e url("../../icon/icon-reload.png") center no-repeat;
            background-size: auto 0.4rem;
        }
    </style>
</head>

<body>
<section class="member_section footer-section">

    <div class="member_info  f30 c-fff bg-cover" id="userbg" style="background: url(../../icon/bg-person-default.png); ">
        <div class="member-share" style="height: 100%;"></div>
        <div id="header" style="position: relative;z-index: 9">
            <header class="member_header">
                <div class="header-left">
                    <div class="nav-left" tapmode onclick="commonUrl('member_info')"><div class="">编辑</div></div>
                </div>
                <div class="header-right">
                    <div tapmode onclick="commonUrl('msg')" class="nav-right">
                        <div class="msg-notice"><img src="../../icon/message.png"/><span id="msgPoint" style="display: none;"></span></div>
                    </div>
                    <div tapmode onclick="commonUrl('setting')" class="nav-right">
                        <div class="msg-notice"><img src="../../icon/setting.png"/></div>
                    </div>
                </div>
            </header>
        </div>
        <div class="pl30 pr30" style="position: relative;z-index: 9">

            <div class="between mt60">
                <div class="userRelative" style="width: 1.3rem;height: 1.3rem;">
                    <div class="member_head bg-cover" tapmode onclick="commonUrl('member_info')"
                                                                                     style="background: url()"></div>
                    <span class="attestation" style="display: none"></span>
                </div>
                <div class="member_days">0</div>
            </div>
            <div class="mt10 line_center"><span tapmode onclick="commonUrl('member_info')" id="nickname"></span>
                <div class="member_sex" id="sex1"><img src="../../icon/sex1.png"/></div>
                <div class="member_sex" id="sex2" style="display: none;"><img src="../../icon/sex2.png"/></div>
            </div>
            <div class="mt20 line_center between">
                <div class="line_center">
                    <div class="line_center"><span tapmode onclick="commonUrl('myScore')" class="f18 member_score"
                                                   id="integral">0分</span></div>
                    <div id='evaluate' class="ml20">
                        <img src="../../icon/lvl.png" class="icon-lvl"/>
                        <img src="../../icon/lvl.png" class="icon-lvl"/>
                        <img src="../../icon/lvl.png" class="icon-lvl"/>
                        <img src="../../icon/lvl.png" class="icon-lvl"/>
                        <img src="../../icon/lvl.png" class="icon-lvl"/>
                    </div>
                </div>
                <img class="camera" tapmode onclick="uploadbg()" src="../../icon/icon-camera.png"/>
            </div>
            <ul class="member_hz_list line_center">
                <!--<li><img src="../../icon/icon-hz01.png" /></li>-->
            </ul>
            <div class=" f24 mt20 "><span id="autograph"></span>
            </div>

        </div>
        <ul class="member_box f26 c-666" style="left: 0.3rem;">
            <li tapmode onclick="commonUrl('myGetLike')">
                <div id="fabulous_number">0</div>
                <div class="mt10">获赞</div>
            </li>
            <li tapmode onclick="commonUrl('myFans')" style="flex: 1!important;">
                <div id="fans">0</div>
                <div class="mt10">粉丝</div>
            </li>
            <li tapmode onclick="commonUrl('myLike')">
                <div id="follow">0</div>
                <div class="mt10">关注</div>
            </li>
        </ul>

    </div>

    <ul class="pl30 pr30 pt70 member_navto f30 c-666 mt2">
        <li tapmode onclick="commonUrl('huizhang')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m1.png"/></div>
                我的徽章
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('schoolRz')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m2.png"/></div>
                学生认证
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('myPublish')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m3.png"/></div>
                我的发表
            </div>
            <div class="member_nav_right"><span id="invitation_count">0</span><img class="ml30 arr_move"
                                                                                  src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('myActivity')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m4.png"/></div>
                我的需求
            </div>
            <div class="member_nav_right"><span id="activity_count">0</span><img class="ml30 arr_move"
                                                                                src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('myCollection')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m5.png"/></div>
                我的收藏
            </div>
            <div class="member_nav_right"><span id="collection_count">0</span><img class="ml30 arr_move"
                                                                                  src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('iLike')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m6.png"/></div>
                我赞过的
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('tougao')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m7.png"/></div>
                投稿
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('record')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m8.png"/></div>
                浏览记录
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="openModel()">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m10.png"/></div>
                推荐给好友
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
        <li tapmode onclick="commonUrl('bubble')">
            <div class="line_center">
                <div class="navto_icon"><img class="mr20 " src="../../icon/icon-m9.png"/></div>
                档案馆
            </div>
            <div class="member_nav_right"><img class="ml30 arr_move" src='../../icon/move.png'/></div>
        </li>
    </ul>

</section>

<div class="fixed-btn" style="bottom: 2rem;">
    <a href="javascript:void(0);" tapmode onclick="loadPage()" class="reload-view"></a>
</div>

<div id="footer" class="border-t">
    <ul class="flex-wrap">
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">首页</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">圈子</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">
            <div class="school-logo">
                <img id="school_path" src="" alt="">
            </div>
        </li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">在看</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">我的</li>
    </ul>
</div>


<!-- 右上角操作 -->
<div class="action-model model" tapmode onclick="closeModel()">
    <div class="action-view" tapmode onclick="stopModel(event)">
        <h6 class="shareTitle">分享</h6>
        <a href="javascript:void(0);" tapmode onclick="closeModel(event)" class="model-close"></a>
        <div class="model-detail">
            <ul>
                <li tapmode onclick="shareWx(event)" class="threeShare">
                    <div class="share-icon icon1"></div>
                    <p>微信</p>
                </li>
                <li tapmode onclick="shareWxq(event)" class="threeShare">
                    <div class="share-icon icon2"></div>
                    <p>朋友圈</p>
                </li>
                <li tapmode onclick="shareQq(event)" class="threeShare">
                    <div class="share-icon icon3"></div>
                    <p>QQ</p>
                </li>
                <li tapmode onclick="shareQzone(event)" class="threeShare">
                    <div class="share-icon icon4"></div>
                    <p>QQ空间</p>
                </li>
                <li tapmode onclick="shareWb(event)" class="threeShare">
                    <div class="share-icon icon5"></div>
                    <p>微博</p>
                </li>
                <li tapmode class="copy" onclick="copyLink()">
                    <div class="share-icon icon-copy"></div>
                    <p>复制链接</p>
                </li>
            </ul>
        </div>
        <!--<div class="shade-user">
            <a href="javascript:void(0);" class="shade-btn"><span>屏蔽此人</span></a>
        </div>-->
    </div>
</div>
<!-- 右上角操作 end -->

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var _model = $(".model");
    var shareTitle = '大学情报局';//分享title
    var shareInfo = '助力你的大学生活';//分享info
    var shareImg = 'widget://icon/logo.png';//分享图片
    var shareLink = '';//分享链接
    apiready = function () {
        $api.fixStatusBar($api.dom('#header'));
        api.setStatusBarStyle({
            style: 'light', //设置APP状态栏字体色
            color: 'rgba(255,255,255,0)', //设置APP状态栏背景色
        });
        // setFixStatusBar(); //设置状态栏

        //监听资料修改过后修改用户首页资料
        api.addEventListener({
            name: 'memberInfo'
        }, function (ret, err) {
            getMemberInfo()
        });

        //监听消息
        api.addEventListener({
            name: 'msgStatus'
        }, function (ret, err) {
            getMemberInfo()
        });



        //监听返回键
        // tabNavListener();
        ExitApp()


        // getMemberInfo()
        /*//下拉刷新
        dropDownRefresh(function () {
            getMemberInfo(1)
        })*/
        // isIosX()


        storageUserInfo()

        SystemCheckVersion(1)


    }

    //推荐给好友
    function copyLink() {
        var text = shareLink;
        copy(text);
    }
    //开启弹窗
    function openModel() {

        getInviteLinks()
        _model.addClass('showModel');
        setTimeout(function () {
            _model.find('.action-view').addClass('showView');
        }, 10)
    }

    //阻止事件冒泡
    function stopModel(event) {
        event.stopPropagation();
    }

    //关闭弹窗
    function closeModel(event) {
        if (event) {
            event.stopPropagation();
        }
        _model.find('.action-view').removeClass('showView');
        setTimeout(function () {
            _model.removeClass('showModel');
        }, 500)
    }
    function getInviteLinks() {
        var param = {
            token: $api.getStorage('token')
        }
        getAjax(Interface.share_login,param,function (res) {

            if(isDefine(res.data)){
                shareLink = res.data.url;
            }
        },function (error) {

        })

    }



    function storageUserInfo() {
        var data = $api.getStorage('userInfo');

        //消息提示
        var notice_num = 0;
        if(data.notice_num == 0){
            $('#msgPoint').hide()
        }else {
            if(data.notice_num>99){
                notice_num = '99+';
            }else {
                notice_num = data.notice_num;
            }
            $('#msgPoint').show().html(notice_num)
        }

        //头像
        $(".member_head").css({background: 'url(' + ajaxUrl + data.icon_path + ')'});
        if(isDefine(data.attestation_status)){
            if(data.attestation_status==1 || data.attestation_status==3){
                $(".attestation").hide();
            }else {
                $(".attestation").show();
            }
        }
        //昵称
        $("#nickname").html(data.name);
        //性别 1男  2女  0保密
        if (data.sex == 1) {
            $("#sex2").show();
            $("#sex1").hide();
        } else if (data.sex == 2) {
            $("#sex2").hide();
            $("#sex1").show();
        } else {
            $("#sex2,#sex1").hide();
        }
        if(isDefine(data.school_path)){
            $('#school_path').attr('src', ajaxUrl + data.school_path);
            $api.setStorage('schoolPath', ajaxUrl + data.school_path);
            $api.setStorage('schoolPath_status', 1);
        }else {
            $('#school_path').attr('src', '../../icon/logo.png');
            $api.setStorage('schoolPath', '../../icon/logo.png');
            $api.setStorage('schoolPath_status', 2);
        }
        api.sendEvent({
            name: 'schoolPathStatus',
        });

        //个性签名
        if (isDefine(data.autograph) && data.autograph != 0) {
            $("#autograph").html(data.autograph+'<img class="ml10" tapmode onclick="commonUrl(\'member_info\',{fouse:true})" style="width: .23rem;display: inline-block;" src="../../icon/bi.png"/>');
        }else {
            $("#autograph").html(commonNote+'<img class="ml10" tapmode onclick="commonUrl(\'member_info\',{fouse:true})" style="width: .23rem;display: inline-block;" src="../../icon/bi.png"/>');
        }
        //加入天数
        $(".member_days").html(data.days);
        //积分
        $("#integral").html(data.integral + 'ml');

        //获得的徽章
        if (isDefine(data.badge_path)) {
            var hzHtml = '';
            for (var j = 0; j < data.badge_path.length; j++) {
                hzHtml += '<li><img src="' + ajaxUrl + data.badge_path[j] + '" /></li>'
            }
            $(".member_hz_list").html(hzHtml);
        }
        //背景图片
        $("#userbg").css({background: 'url(' + ajaxUrl + data.background_path + ')'});
        //数量
        if(isDefine(data.invitation_count)){
            $("#invitation_count").html(data.invitation_count);
        }else {
            $("#invitation_count").html(0);
        }
        if(isDefine(data.activity_count)){
            $("#activity_count").html(data.activity_count);
        }else {
            $("#activity_count").html(0);
        }
        if(isDefine(data.collection_count)){
            $("#collection_count").html(data.collection_count);
        }else {
            $("#collection_count").html(0);
        }
        $("#fans").html(data.fans);
        $("#follow").html(data.follow);
        $("#fabulous_number").html(data.fabulous_number);
        //星级
        if (isDefine(data.evaluate)) {

            if (data.evaluate != 0) {

                var starList = '';
                for (var i = 0; i < data.evaluate; i++) {
                    starList += '<img src="../../icon/lvl.png" class="icon-lvl"/>'
                }
                var nostar = 5 - parseInt(data.evaluate);
                for (var i = 0; i < nostar; i++) {
                    starList += '<img src="../../icon/icon-lvl.png" class="icon-lvl"/>'
                }
                $("#evaluate").html(starList)
            }
        }
    }

    //刷新页面
    function loadPage() {
        api.sendEvent({
            name: 'memberInfo',
            extra: {}
        });
    }

    //获取用户信息
    function getMemberInfo() {
        var param = {
            token: $api.getStorage('token')
        }
        pop.loading();
        getAjax(Interface.memberIndex, param, function (res) {
            var data = res.data;

            $api.setStorage('userInfo',data);

            //消息提示
            var notice_num = 0;
            if(data.notice_num == 0){
                $('#msgPoint').hide()
            }else {
                if(data.notice_num>99){
                    notice_num = '99+';
                }else {
                    notice_num = data.notice_num;
                }
                $('#msgPoint').show().html(notice_num)
            }

            //头像
            $(".member_head").css({background: 'url(' + ajaxUrl + data.icon_path + ')'});
            if(isDefine(data.attestation_status)){
                if(data.attestation_status==1 || data.attestation_status==3){
                    $(".attestation").hide();
                }else {
                    $(".attestation").show();
                }
            }
            //昵称
            $("#nickname").html(data.name);
            //性别 1男  2女  0保密
            if (data.sex == 1) {
                $("#sex2").show();
                $("#sex1").hide();
            } else if (data.sex == 2) {
                $("#sex2").hide();
                $("#sex1").show();
            } else {
                $("#sex2,#sex1").hide();
            }
            if(isDefine(data.school_path)){
                $('#school_path').attr('src', ajaxUrl + data.school_path);
                $api.setStorage('schoolPath', ajaxUrl + data.school_path);
                $api.setStorage('schoolPath_status', 1);
            }else {
                $('#school_path').attr('src', '../../icon/logo.png');
                $api.setStorage('schoolPath', '../../icon/logo.png');
                $api.setStorage('schoolPath_status', 2);
            }
            api.sendEvent({
                name: 'schoolPathStatus',
            });

            //个性签名
            if (isDefine(data.autograph) && data.autograph != 0) {
                $("#autograph").html(data.autograph+'<img class="ml10" tapmode onclick="commonUrl(\'member_info\',{fouse:true})" style="width: .23rem;display: inline-block;" src="../../icon/bi.png"/>');
            }else {
                $("#autograph").html(commonNote+'<img class="ml10" tapmode onclick="commonUrl(\'member_info\',{fouse:true})" style="width: .23rem;display: inline-block;" src="../../icon/bi.png"/>');
            }
            //加入天数
            $(".member_days").html(data.days);
            //积分
            $("#integral").html(data.integral + 'ml');

            //获得的徽章
            if (isDefine(data.badge_path)) {
                var hzHtml = '';
                for (var j = 0; j < data.badge_path.length; j++) {
                    hzHtml += '<li><img src="' + ajaxUrl + data.badge_path[j] + '" /></li>'
                }
                $(".member_hz_list").html(hzHtml);
            }
            //背景图片
            $("#userbg").css({background: 'url(' + ajaxUrl + data.background_path + ')'});
            //数量
            $("#invitation_count").html(data.invitation_count);
            $("#activity_count").html(data.activity_count);
            $("#collection_count").html(data.collection_count);
            $("#fans").html(data.fans);
            $("#follow").html(data.follow);
            $("#fabulous_number").html(data.fabulous_number);
            //星级
            if (isDefine(data.evaluate)) {

                if (data.evaluate != 0) {

                    var starList = '';
                    for (var i = 0; i < data.evaluate; i++) {
                        starList += '<img src="../../icon/lvl.png" class="icon-lvl"/>'
                    }
                    var nostar = 5 - parseInt(data.evaluate);
                    for (var i = 0; i < nostar; i++) {
                        starList += '<img src="../../icon/icon-lvl.png" class="icon-lvl"/>'
                    }
                    $("#evaluate").html(starList)
                }
            }
            pop.close();
        }, function (error) {
            pop.close();
            pop.notice('读取数据失败');
        })
    }

    //上传背景图片
    function uploadbg() {
        uploadHeadPic(function (res) {
            var param = {
                token: $api.getStorage('token'),
                background_icon: res.icon
            }
            getAjax(Interface.edit_member, param, function (res) {

                pop.notice('更换成功');
                getMemberInfo();

            }, function (error) {
                pop.notice('更换背景失败');
            })
        })
    }

    //scene:session（会话）timeline（朋友圈）favorite（收藏）
    //title:标题
    //thumb 图标
    //contentUrl 分享的地址
    //type：1新闻 2帖子 3赛况 4活动

    //微信好友分享
    function shareWx(){
        var p = {
            apiKey: '',
            scene: 'session',
            title: shareTitle,
            thumb: shareImg,
            contentUrl: shareLink
        };
        wxpyqFX(p);
    }
    //朋友圈
    function shareWxq(){
        var p = {
            apiKey: '',
            scene: 'timeline',
            title: shareTitle,
            thumb: 'widget://icon/logo22.png',
            contentUrl: shareLink
        };
        wxpyqFX(p);
    }
    //qq好友
    function shareQq(){
        var p = {
            url: shareLink,
            title: shareTitle,
            description: shareInfo,
            imgUrl: shareImg,
            type:'QFriend'
        }
        qqfx(p);
    }

    //qq空间
    function shareQzone(){
        var p = {
            url: shareLink,
            title: shareTitle,
            description: shareInfo,
            imgUrl: shareImg,
            type:'QZone'
        }
        qqfx(p);
    }

    //微博
    function shareWb(){
        var p = {
            apiKey: '',
            scene: 'session',
            title: shareTitle,
            description: shareInfo,
            thumb: shareImg,
            contentUrl: shareLink,
        };
        weibo_authorize(p);
    }



</script>
